Topic: List of online avatars at top of forum

I had this working using the below code in version 1.2
Does anyone know what I can do to make it work in 1.3?
I don't want to just paste it in in case I mess everything up smile

What do you think, will the below code work?

<!-- LIST OF ONLINE AVATARS -->

<?php

if ($pun_config['o_users_online'] == '1')
{
    // Fetch users online info and generate strings for output
    $num_guests = 0;
    $users = array();
    $result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());

    while ($pun_user_online = $db->fetch_assoc($result))
    {
        if ($pun_user_online['user_id'] > 1)
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$pun_user_online['user_id'].'.gif'))
                $users[] = "\n\t\t\t\t".'<dd><a title="'.pun_htmlspecialchars($pun_user_online['ident']).'" href="profile.php?id='.$pun_user_online['user_id'].'"><img src="'.$pun_config['o_avatars_dir'].'/'.$pun_user_online['user_id'].'.gif" '.$img_size[3].' alt="" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$pun_user_online['user_id'].'.jpg'))
                $users[] = "\n\t\t\t\t".'<dd><a title="'.pun_htmlspecialchars($pun_user_online['ident']).'" href="profile.php?id='.$pun_user_online['user_id'].'"><img src="'.$pun_config['o_avatars_dir'].'/'.$pun_user_online['user_id'].'.jpg" '.$img_size[3].' alt="" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$pun_user_online['user_id'].'.png'))
                $users[] = "\n\t\t\t\t".'<dd><a title="'.pun_htmlspecialchars($pun_user_online['ident']).'" href="profile.php?id='.$pun_user_online['user_id'].'"><img src="'.$pun_config['o_avatars_dir'].'/'.$pun_user_online['user_id'].'.png" '.$img_size[3].' alt="" /></a>'; 
            else
                $users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
        }
        else
            ++$num_guests;
    }

    $num_users = count($users);
    /*echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";*/


    if ($num_users > 0)
        echo "\t\t\t".'<dl id="onlinelist" class= "clearb"><!--<a href="/"><img src="/img/avatar-logo.jpg" alt="royton"></a>-->'."\n\t\t\t\t".'<dt><strong>'.$lang_index['Online'].'</strong></dt>'."\t\t\t\t".implode('</dd> ', $users).' 
        
        </dd>'."\n\t\t\t".'</dl>'."\n";
    else
        echo "\t\t\t".'<div class="clearer"></div>'."\n";

}
else
echo "\t\t".'</dl>'."\n\t\t\t".'<div class="clearer"></div>'."\n";


?>



<!--END OF ONLINE AVATARS -->

Re: List of online avatars at top of forum

I tested and it doesn't work sad
Does anyone think they can get this working for me?
I ideally want a block of code that I can place wherever in the template > main.tpl file that I like so that a list of avatars showing who is online appears. It worked really really really well for my community. We all miss it very much

There might be a small bit of money if someone thinks they can code this for me smile

Re: List of online avatars at top of forum

If someone can make this mod work in 1.3 I will be happy to donate a small amount (£20?) to a charity of your choice.

I'm a bit desperate for this mod smile

Re: List of online avatars at top of forum

b-ump!
My users are still desparate for this one.
I've got a list of names at the top as you can see here:
http://www.eroyton.co.uk/forum/search.p … how_recent

But I really need a list of avatars, not names.
Any help appreciated. This was possible in 1.2 so I'm hoping it isn't too hard in 1.3

£10 to a charity of your choice if you can get this working for me smile

Re: List of online avatars at top of forum

This could be VERY handy. Any Gifted Soul who want to make it into extension?

Re: List of online avatars at top of forum

my users have been LOVING it for the past year on 1.2

Re: List of online avatars at top of forum

Fine... I'll make it... just tell me how you expect it to look like.

8

Re: List of online avatars at top of forum

Garciat wrote:

Fine... I'll make it... just tell me how you expect it to look like.

http://www.gaiaonlinefan.com/files/2008/06/gaia21.jpg

Visit Gaia Online, to get ideas.

Re: List of online avatars at top of forum

Like the "Friends" table, right? Unless you mean the flying characters...

10

Re: List of online avatars at top of forum

Yeah, the friends table.

It will have to be configurable, as to how many you want to see. On a busy forum, you couldn't fit everyone.

You can base it on activity, like the last 10 that have been active, it's constantly changing. Come to think of it, you may have to get a clearance from the epileptic community.

11

Re: List of online avatars at top of forum

http://i247.photobucket.com/albums/gg135/garcia-t/avatars.jpg

Is that good?

Re: List of online avatars at top of forum

Hi Garciat,
Here is how we had it working in 1.2:

http://farm4.static.flickr.com/3076/2569629039_1d785c86e4_o.jpg

It works really well to strengthen the sense of community on a forum. It makes you feel like you're not just sat at a computer but you're amongst friends. The text list of online users doesn't have the same effect.

Your example looks brilliant, well done for figuring that out. However, for my purposes I'd want to have it so that there was no heading above the list and no text-alternative of the username. It should just be a list of avatars. As you can see above, it makes for an exciting and dynamic effect.

Cheers Garciat, I have a few members who are desparate for this so once it is working I'll be asking them to consider donating to you for your hard work. If you have PayPal I'm sure a few members would send you something (me included).

THANKS FOR YOUR HARD WORK SO FAR smile
I'm excited by this mod smile

13

Re: List of online avatars at top of forum

Garciat wrote:

Is that good?

Yes, that looks nice.

14 (edited by User33 2008-12-17 14:53)

Re: List of online avatars at top of forum

Well, currently, the mod is not an extension, it's just a file that you can include in your main.tpl file.

If you want me to make it an extension, let me know (this could take a bit longer). I'll start working on the Gravatar extension right now.

Re: List of online avatars at top of forum

Garciat wrote:

Well, currently, the mod is not an extension, it's just a file that you can include in your main.tpl file.

I'd love to receive that file Garciat. Any chance of uploading it to somewhere or emailing the code to eroyton@gmail.com ?

If you want me to make it an extension, let me know (this could take a bit longer)

I can get by with a file include and instructions for now, definitely. But in the long term I reckon an online avatar extension would be very popular smile

16 (edited by User33 2008-12-17 16:12)

Re: List of online avatars at top of forum

  1. Save this file to 'include/user/user_avatars.php'.

  2. Add '<!-- forum_include "user_avatars.php" -->' after '<!-- forum_announcement -->' on your main.tpl.

That's it smile

Edit: There are some options you can change on 'user_avatars.php'.

Re: List of online avatars at top of forum

Brilliant. I love it. I'll test it tonight and post any feedback.
Do you have a paypal email address?
If so please post it here or send it to me at eRoyton@gmail.com
I'm going to send you £5, not much I know but I'll also encourage members of my forum to send some too. They've been begging for this feature.

Cheers Garciat. GOOD JOB!!

18 (edited by esupergood 2008-12-17 16:44)

Re: List of online avatars at top of forum

See this in action here:
http://www.eroyton.co.uk/forum/

There are likely to be 6 or 7 people online at about 9pm British time.

19 (edited by whatrevolution 2008-12-17 17:32)

Re: List of online avatars at top of forum

Parse error: syntax error, unexpected T_ENDIF in <snip>/forum/include/user/user_avatars.php on line 43

<?php
##########################################################
//Change this to how many avatars you want to be displayed
$limit = 5;

//If you want a clean look, change this to true
$clean = true;
##########################################################

if (substr(FORUM_PAGE, 0, 7) !== 'profile') {

if ($forum_config['o_users_online'] == '1')
{
    $array = array(
        'SELECT'    => 'o.id, o.username',
        'FROM'        => 'users AS o',
        'JOINS'        => array(
            array(
                'LEFT JOIN'        => 'online AS e',
                'ON'            => '(e.user_id=o.id)'
            )
        ),
        'WHERE'        => 'e.idle=0 AND o.id!=1',
        'ORDER BY'    => 'e.logged DESC',
        'LIMIT'        => $limit
    );
    $process = $forum_db->query_build($array) or error(__FILE__, __LINE__);
    
    while($cur_user = $forum_db->fetch_assoc($process))
    {
        $pic_url = preg_replace("/\<img src=\"([^\"]+)\"(.*)\/\>/i", "$1", generate_avatar_markup($cur_user['id']));
        $avatars[] = '<a href="'.forum_link($forum_url['user'], $cur_user['id']).'" style="float:left;margin:10px;text-align:center;"><span style="display:block;width:'.$forum_config['o_avatars_width'].'px;height:'.$forum_config['o_avatars_height'].'px;background:transparent url(\''.$pic_url.'\') center center no-repeat;"></span>'.$cur_user['username'].'</a>';
    }
}

require FORUM_ROOT.'lang/'.$forum_user['language'].'/index.php';

?><div id="brd-user_avatars"><?php
if (!$clean) { ?>
<div class="main-head"<?php echo (FORUM_PAGE == 'index') ? '' : ' style="margin-top:1em"' ?>>
    <h2 class="hn"><span>Online Users</span></h2>
</div>
<?php } ?>
<div class="gen-content" style="<?php echo (FORUM_PAGE == 'index') ? 'margin-bottom:1em;' : ''; echo ($clean) ? 'background:transparent;border:0;margin-top:1em;' : '' ?>padding:0">
    <?php echo ($forum_db->num_rows($process)>0) ? implode("\n\t", $avatars) : '<p style="padding: 5px 10px;">- No online users -</p>' ?>
</div>
</div>
<?php } ?>

Re: List of online avatars at top of forum

So far, so good for me. It would be great if I had the option to remove the username from underneath. Another little true/false option would be great for that. Also, it would be good if the "clean" version would completely strip out all formating so that it looked like this:

http://farm4.static.flickr.com/3076/2569629039_1d785c86e4_o.jpg

Loving it so far.

Re: List of online avatars at top of forum

Here you go. 1.3 with online avatars
http://farm4.static.flickr.com/3175/3116373086_20b5997492_o.jpg

brill!

22

Re: List of online avatars at top of forum

@whatrevolution: It worked perfectly for me.

@esupergood: Re-download the file, I added an option to hide the names.

Re: List of online avatars at top of forum

Garciat wrote:
  1. Save this file to 'include/user/user_avatars.php'.

  2. Add '<!-- forum_include "user_avatars.php" -->' after '<!-- forum_announcement -->' on your main.tpl.

That's it smile

Edit: There are some options you can change on 'user_avatars.php'.


Cool. But what will happend if no one is online? And can you give us some tips what we can change on the user_avatars.php, because this could be really cool if the avatars showing base on forum post (eg. top poster). Thanks for the effort.

24 (edited by whatrevolution 2008-12-17 17:55)

Re: List of online avatars at top of forum

Garciat wrote:

@whatrevolution: It worked perfectly for me.

Mine did not, unfortunately.  Switching to curly brackets on 'if {}' solved it.  I added an outer container so I could id="" and control it in CSS.  I placed an image to the left, and right of that container.

StyleName_cs.css:

.brd #brd-user_avatars_left {
    background:
      url("/images/statue_facing_right.gif")
      top left no-repeat
      ;
    height: 133px;
    width: 89px;
    float: left;
    }

.brd #brd-user_avatars_right {
    background:
      url("/images/statue_facing_left.gif")
      top left no-repeat
      ;
    height: 133px;
    width: 89px;
    float: right;
    }

.brd #brd-user_avatars {
    margin-left: 100px;
    margin-right: 100px;
    }

main.tpl:

<div id="brd-main">
    <!-- forum_main_title -->
    <!-- forum_crumbs_top -->
    <!-- forum_main_menu -->
    <!-- forum_main_pagepost_top -->
    <!-- forum_main -->
    <!-- forum_main_pagepost_end -->
    <!-- forum_crumbs_end -->
  <div id="brd-user_avatars_left">&nbsp;</div>
  <div id="brd-user_avatars_right">&nbsp;</div>
  <!-- forum_include "user_avatars.php" -->
</div>

Edit:

PHP Version     5.2.0-8+etch13
System     Linux 2.6.24-19-xen #1 SMP Sat Jul 12 00:15:59 UTC 2008 x86_64
Build Date     Sep 30 2008 18:29:09
Server API     Apache 2.0 Handler 

Re: List of online avatars at top of forum

sonofsinner wrote:

Cool. But what will happend if no one is online?

That is the same as asking, "When a tree falls in an empty forest, does it make a sound?"  Clearly, no human will ever know.